﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;

namespace PSE.Deployment.SetupBase.Configuration
{
    [Serializable]
    public class SystemInfo
    {
        [XmlAttribute()]
        public string Id { get; set; }
        [XmlAttribute()]
        public string Description { get; set; }
        public PSE.Framework.Common.Version Version { get; set; }
        public List<Group> Groups { get; set; }
        public UpdateInfo UpdateInfo { get; set; }
        public SystemInfoCollection Dependencies { get; set; }
        public SystemInfoCollection Children { get; set; }
        public List<string> Process { get; set; }

        public SystemInfo()
        {
            this.Groups = new List<Group>();
            this.UpdateInfo = new UpdateInfo();
            this.Dependencies = new SystemInfoCollection();
            this.Children = new SystemInfoCollection();
            this.Process = new List<string>();
        }

        public SystemInfo Clone()
        {
            SystemInfo s = new SystemInfo();
            s.Id = this.Id;
            s.Description = this.Description;
            s.Version = this.Version;

            //foreach (Group group in this.Groups)
            //{
            //    s.Groups.Add(group.Clone());
            //}

            s.UpdateInfo = this.UpdateInfo;
            s.Process = this.Process;
            s.Dependencies = this.Dependencies;
            s.Children = this.Children;
            return s;
        }

        public override string ToString()
        {
            return this.Id + "-v" + this.Version.Major.ToString();
        }
    }
}
